const path = require("path"); //引入path模块
const resolve = (dir) => path.join(__dirname, dir);
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
  transpileDependencies: true,
  chainWebpack: config => {
    config
      .plugin('html')
      .tap(args => {
        args[0].title = '西南空管航空服务平台';
        return args
      })
    // ./src/versionPlugin.js是plugin的位置
    // const VersionPlugin = require('./compile.js')
    // config.plugin('version').use(VersionPlugin).tap(args => {
    //   // 此处添加的参数可在versionPlugin的构造函数中获取
    //   return args
    // })
    config.resolve.alias
      //set第一个参数：设置的别名，第二个参数：设置的路径
      .set("@", resolve("./src"))
      .set("components", resolve("./src/components"))
      .set("assets", resolve("./src/assets"))
      .set("views", resolve("./src/views"))
      .set("utils", resolve("./src/utils"))
      .set("lib", resolve("./src/lib"))
      .set("api", resolve("./src/api"))
      .set("request", resolve("./src/request"))
      .set("constant", resolve("./src/constant"))
      .set("modules", resolve("./node_modules"))
  },
  devServer: {
    proxy: {
      "/model": {
        target: "http://192.168.0.6:7081",
        changeOrigin: true,
      },
      "/image": {
        target: "http://192.168.0.6:7081/image/",
        changeOrigin: true,
        pathRewrite: {
          '^/image': ''
        }
      },
    },
    historyApiFallback: true,
    allowedHosts: "all",
  }
})
